import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class BottomMenuDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("底部弹框"),
      ),
      body: Container(
        child: RaisedButton(
          textColor: Colors.white,
          color: Colors.red,
          child: Text('弹框'),
          onPressed: () {
            _showBottomMenu(context);
          },
        ),
      ),
    );
  }

  //弹出底部菜单
  void _showBottomMenu(BuildContext context) {
    showModalBottomSheet(
        context: context,
        //isScrollControlled: true,//设为true，此时为全屏展示

        backgroundColor: Colors.white,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(10),
            topRight: Radius.circular(10),
          ),
        ),
        builder: (BuildContext context) {
          return Container(
            child: SingleChildScrollView(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  ListTile(
                    title: Text(
                      '拍照',
                      textAlign: TextAlign.center,
                      style: TextStyle(fontSize: 16, color: Colors.deepOrange),
                    ),
                    onTap: () {
                      // _takePhoto();
                      Navigator.pop(context);
                    },
                  ),
                  Divider(
                    height: 1,
                  ),
                  ListTile(
                    title: Text(
                      '相册',
                      textAlign: TextAlign.center,
                      style: TextStyle(fontSize: 16, color: Colors.deepOrange),
                    ),
                    onTap: () {
                      //_openPhotoAlbum();
                      Navigator.pop(context);
                    },
                  ),
                  Container(
                    color: Colors.grey[100],
                    height: 10,
                  ),
                  ListTile(
                    title: Text(
                      '取消',
                      textAlign: TextAlign.center,
                      style: TextStyle(fontSize: 16, color: Colors.deepOrange),
                    ),
                    onTap: () {
                      Navigator.pop(context);
                    },
                  ),
                ],
              ),
            ),
          );
        });
  }
}
